<template>
  <div class="online-chat">
    <div class="chat-bg">
        <div class="chat-bg-top">
            <div class="chat-bg-top-left">
                <img src="@/assets/images/chat.png" alt="">
                <p>在线咨询</p>
            </div>
            <img @click="closeChat" class="guanbi" src="@/assets/icons/close2.png" alt="">
        </div>
        <div class="container">
            <!-- 左侧聊天面板 -->
            <div class="chat-panel">
                <div class="chat-messages">
                <!-- 客服消息 -->
                <div class="message agent">
                    <div class="message-content">
                        <div class="message-top">
                            <div class="avatar">
                                <img src="@/assets/images/touxiang.png" alt="">
                            </div>
                            <div class="agent-info">
                                <h3>客服小蜜</h3>
                            </div>
                        </div>
                        <div class="message-text">
                            <p>欢迎您的咨询，期待为您服务！</p>
                            <p>留下您的手机号+考试科目，即可申请免费试听/题库，名额有限</p>
                            <div class="message-time">2022-02-15 21:10:58</div>
                        </div>
                    </div>
                </div>

                <!-- 用户消息 -->
                <div class="message user">
                    <div class="message-content1">
                        <p>您好，我想咨询下课程</p>
                        <p>可以电话聊吗？可以微信聊吗？</p>
                        <div class="message-time">2022-02-15 21:10:58</div>
                    </div>
                </div>
            </div>

            <div class="chat-input">
            <div class="phone-wechat">
            <p>可以电话聊吗？</p>
            <p>可以微信聊吗？</p>
            </div>
            <div class="input-container">
            <input type="text" placeholder="请输入您想要咨询的内容">
            <button>发送</button>
            </div>
            </div>
            </div>

            <!-- 右侧信息面板 -->
            <div class="info-panel">
                <h2>关于我们</h2>
                <div class="features">
                    <div class="feature-item">
                        <img src="@/assets/images/about.png" alt="">
                    </div>
                </div>
            </div>
        </div>
        </div>
    </div>
</template>
<script>
export default {
  data() {
    return {
      newMessage: '',
      messages: [
        {
          sender: '客服小蜜',
          timestamp: '2022-02-15 21:10:58',
          text: '24年在线教学经验。\n留下您的手机号+考试科目，即可申请免费试听/题库，名额有限'
        },
        {
          sender: '游客',
          timestamp: '2022-02-15 21:10:58',
          text: '您好，我想咨询下课程'
        }
      ]
    };
  },
  methods: {
    sendMessage() {
      if (this.newMessage.trim() !== '') {
        this.messages.push({
          sender: '游客',
          timestamp: new Date().toLocaleString(),
          text: this.newMessage
        });
        this.newMessage = '';
      }
    },
    closeChat() {
        this.$emit('closeChat');
    }
  }
};
</script>
<style scoped>
.online-chat{
    background: rgba(0,0,0,0.5);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
.chat-bg{
    width: 960px;
    height: 80vh;
    /* overflow: scroll; */
    background: #FFFFFF;
}
.chat-bg-top{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
}
.chat-bg-top-left{
    display: flex;
    align-items: center;
}
.chat-bg-top-left img{
    width: 52px;
    height: 52px;
    margin-right: 10px;
}
.chat-bg-top-left p{
    font-weight: 400;
    font-size: 20px;
    color: #000000;
    margin-bottom: 0px;
}
.guanbi{
    width: 34px;
    height: 34px;
}
.container {
    width: 96%;
    max-width: 900px;
    background: white;
    border-radius: 15px;
    box-shadow: 0px 0px 16px 0px rgba(0,0,0,0.13);
    overflow: hidden;
    display: flex;
    height: 70vh;
    margin: auto;
}
.chat-header{
    width: 94%;
    margin: auto;
    height: 80px;
    background: linear-gradient( 90deg, #3881F8 0%, #5EA3FE 100%);
}
    
/* 左侧信息面板 */
.info-panel {
    width: 35%;
    background: #FFFFFF;
    padding: 30px 25px;
    display: flex;
    flex-direction: column;
}

.info-panel h2 {
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 20px;
    color: #0080FF;
}
.info-panel img{
    width: 100%;
    /* margin: 0 auto; */
}
    
.features {
    flex-grow: 1;
}

.feature-item {
    display: flex;
    margin-bottom: 22px;
}
    
    
/* 右侧聊天区域 */
.chat-panel {
    width: 65%;
    display: flex;
    flex-direction: column;
}
    
.message-top {
    /* padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
    background: white; */
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}
    
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}
.avatar img{
    width: 100%;
}
    
.agent-info h3 {
    font-size: 18px;
    margin-bottom: 5px;
    color: #333;
}
    
.agent-info p {
    font-size: 13px;
    color: #07C160;
    font-weight: 500;
}
    
/* 聊天消息区域 */
.chat-messages {
    flex-grow: 1;
    padding: 25px;
    overflow-y: auto;
    background: #f9fbfd;
}
    
.message {
    display: flex;
    margin-bottom: 20px;
}
    
.message.agent {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}
    
.message-text {
    max-width: 75%;
    padding: 15px;
    border-radius: 12px;
    position: relative;
    line-height: 1.5;
    font-size: 14px;
    text-align: left;
}
    
.message.agent .message-text {
    background: #edf2f7;
    color: #2d3748;
    border-top-left-radius: 0;
}
    
.message.user .message-content1 {
    background: linear-gradient( 90deg, #3881F8 0%, #5EA3FE 100%);
    border-radius: 8px;
    font-weight: 400;
    font-size: 14px;
    color: #FFFFFF;
    padding: 15px;
    text-align: left;
}
    
.message-time {
    font-size: 12px;
    color: #fff;
    margin-top: 5px;
    text-align: right;
}
.phone-wechat{
    display: flex;
}
.phone-wechat p{
    width: 126px;
    height: 30px;
    line-height: 30px;
    background: #EDF5FF;
    border-radius: 15px;
    border: 1px solid #78A9FF;
    font-weight: 400;
    font-size: 14px;
    color: #0080FF;
    margin-right: 15px;
}
.input-group {
    display: flex;
    margin-top: 15px;
}
    
.input-group input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px 0 0 8px;
    font-size: 14px;
    outline: none;
    transition: border 0.3s;
}
    
.input-group input:focus {
    border-color: #3498db;
}

.input-group button {
    background: #07C160;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 0 8px 8px 0;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}
    
.input-group button:hover {
    background: #06ad56;
}
    
/* 输入区域 */
.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #f0f0f0;
}
    
.input-container {
    /* display: flex; */
    /* border: 1px solid #e2e8f0; */
    border-radius: 10px;
    overflow: hidden;
}
    
.input-container input {
    flex-grow: 1;
    border: none;
    padding: 15px;
    font-size: 14px;
    outline: none;
    width: 100%;
    height: 156px;
    background: #F0F0F0;
    border-radius: 8px;
}
    
.input-container button {
    border: none;
    cursor: pointer;
    width: 100px;
    height: 40px;
    background: linear-gradient( 90deg, #3881F8 0%, #5EA3FE 100%);
    border-radius: 8px;
    font-weight: 400;
    font-size: 14px;
    color: #FFFFFF;
    display: block;
    margin: 20px 0 20px auto;
}
    
.input-container button i {
    margin-right: 8px;
}

.input-container button:hover {
    background: #06ad56;
}
    
.prompt-text {
    text-align: center;
    font-size: 13px;
    color: #a0aec0;
    margin-top: 10px;
}
    
/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
    }
    
    .info-panel, .chat-panel {
        width: 100%;
    }
    
    .info-panel {
        padding: 20px 15px;
    }
}
</style>